package com.ruyuan.payment.server.service;

import com.ruyuan.payment.server.domain.Notify;
import com.ruyuan.payment.server.mapper.NotifyMapper;
import com.ruyuan.payment.server.util.SnowFlake;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Service
public class NotifyService {

    @Resource
    private NotifyMapper notifyMapper;

    @Resource
    private SnowFlake snowFlake;

    public void add(String channel, String param) {
        Date now = new Date();
        Notify notify = new Notify();
        notify.setId(snowFlake.nextId());
        notify.setChannel(channel);
        notify.setParam(param);
        notify.setCreatedTime(now);

        notifyMapper.insert(notify);
    }
}
